// ------------------------------------------------- \\
// quiz_engine.js : Last modified 14 Oct 1999 by KJS \\
// ------------------------------------------------- \\

function Analyze(sel)
{
	var	selInx = sel.selectedIndex;
	if (selInx == 0)
	{
		self.applet.location.href = "../quiz_eng/quizinst.htm";
	}
	else
	{
		QuizEngine(sel.options[selInx].value);
	}
}

function LoadFigure(name)
{
	var browNet = (navigator.appName.indexOf("Netscape") != -1);
	var browMic = (navigator.appName.indexOf("Microsoft") != -1);

	// calculate the optimal window dimensions
	var winHt = 500;
	var winWd = 500;

	// form features with which to open the window
	var openFeatures = "";
	if (browNet)
	{
		openFeatures = openFeatures + "innerHeight=" + winHt;
		openFeatures = openFeatures + ",innerWidth=" + winWd;
	}
	else
	{
		openFeatures = openFeatures + "height=" + winHt;
		openFeatures = openFeatures + ",width=" + winWd;
	}
	// if a menu page, include toolbar
	if ((name.substr(0,1) == "m") || (browMic))
	{
		openFeatures = openFeatures + ",toolbar=yes";
	}
	else
	{
		openFeatures = openFeatures + ",toolbar=no";
	}

	// set the appearance of the window
	openFeatures = openFeatures + ",location=no";
	openFeatures = openFeatures + ",menubar=no";
	openFeatures = openFeatures + ",resizable=yes";
	openFeatures = openFeatures + ",scrollbars=yes";
	openFeatures = openFeatures + ",status=no";

	// open the window
	if (browNet)
	{
		var win = window.open(name + ".htm","QuizEngineFig",openFeatures,"");
	}
	else if (browMic)
	{
		var win = window.open("../quiz_eng/blank_wh.htm","QuizEngineFig",openFeatures,"");
		win.location.href = name + ".htm";
	}

	// bring the window to the top
	win.focus();
}

function QuizEngine(parms)
{
	var appWd = 430;
	
	var parm = parms.split(",");		// 0: JAR file, 1: type, 2: quesBeg, 3: quesEnd

	// set JAR specific values
	var quesCnt, appHt;
	if		(parm[0] == "0101")	{quesCnt =   8;  appHt = 195;}
	else if (parm[0] == "0102")	{quesCnt =  36;  appHt = 267;}
	else if (parm[0] == "0103")	{quesCnt =  10;  appHt = 189;}

	else if (parm[0] == "0201")	{quesCnt =  37;  appHt = 237;}

	else if (parm[0] == "0301")	{quesCnt =  15;  appHt = 270;}

	else if (parm[0] == "0401")	{quesCnt =  35;  appHt = 237;}
	else if (parm[0] == "0402")	{quesCnt =  12;  appHt = 390;}
	else if (parm[0] == "0403")	{quesCnt =   6;  appHt = 180;}

	else if (parm[0] == "0501")	{quesCnt =  25;  appHt = 237;}
	else if (parm[0] == "0502")	{quesCnt =  32;  appHt = 367;}
	else if (parm[0] == "0503")	{quesCnt =  10;  appHt = 195;}

	else if (parm[0] == "0601")	{quesCnt =  59;  appHt = 235;}
	else if (parm[0] == "0602")	{quesCnt =   2;  appHt = 267;}
	else if (parm[0] == "0603")	{quesCnt =   3;  appHt = 222;}
	else if (parm[0] == "0604")	{quesCnt =  12;  appHt = 240;}

	else if (parm[0] == "0701")	{quesCnt =  83;  appHt = 264;}
	else if (parm[0] == "0702")	{quesCnt =  15;  appHt = 373;}

	else if (parm[0] == "0801")	{quesCnt =  54;  appHt = 237;}
	else if (parm[0] == "0802")	{quesCnt =  13;  appHt = 275;}

	else if (parm[0] == "0901")	{quesCnt =  85;  appHt = 300;}
	else if (parm[0] == "0902")	{quesCnt =  39;  appHt = 390;}
	else if (parm[0] == "0903")	{quesCnt =  29;  appHt = 380;}
	else if (parm[0] == "0904")	{quesCnt =   6;  appHt = 183;}
	else if (parm[0] == "0905")	{quesCnt =   5;  appHt = 180;}
	else if (parm[0] == "0906")	{quesCnt =  11;  appHt = 180;}
	else if (parm[0] == "0907")	{quesCnt =   4;  appHt = 172;}
	else if (parm[0] == "0908")	{quesCnt =   4;  appHt = 172;}
	else if (parm[0] == "0909")	{quesCnt =   4;  appHt = 202;}

	else if (parm[0] == "1001")	{quesCnt =  91;  appHt = 267;}
	else if (parm[0] == "1002")	{quesCnt =  26;  appHt = 390;}
	else if (parm[0] == "1003")	{quesCnt =  16;  appHt = 334;}
	else if (parm[0] == "1004")	{quesCnt =  10;  appHt = 180;}
	else if (parm[0] == "1005")	{quesCnt =   7;  appHt = 195;}
	else if (parm[0] == "1006")	{quesCnt =   3;  appHt = 180;}
	else if (parm[0] == "1007")	{quesCnt =   6;  appHt = 177;}

	else if (parm[0] == "1101")	{quesCnt = 111;  appHt = 252;}
	else if (parm[0] == "1102")	{quesCnt =  27;  appHt = 367;}
	else if (parm[0] == "1103")	{quesCnt =   6;  appHt = 180;}
	else if (parm[0] == "1104")	{quesCnt =   9;  appHt = 177;}
	else if (parm[0] == "1105")	{quesCnt =   8;  appHt = 270;}

	else if (parm[0] == "1201")	{quesCnt =  85;  appHt = 253;}
	else if (parm[0] == "1202")	{quesCnt =  17;  appHt = 307;}
	else if (parm[0] == "1203")	{quesCnt =  24;  appHt = 195;}

	else if (parm[0] == "1301")	{quesCnt =  21;  appHt = 282;}
	else if (parm[0] == "1302")	{quesCnt =  29;  appHt = 210;}
	else if (parm[0] == "1303")	{quesCnt =  27;  appHt = 390;}
	else if (parm[0] == "1304")	{quesCnt =   9;  appHt = 195;}
	else if (parm[0] == "1305")	{quesCnt =   3;  appHt = 180;}
	else if (parm[0] == "1306")	{quesCnt =   4;  appHt = 180;}
	else if (parm[0] == "1307")	{quesCnt =   3;  appHt = 180;}
	else if (parm[0] == "1308")	{quesCnt =   3;  appHt = 180;}

	else if (parm[0] == "1401")	{quesCnt =  16;  appHt = 261;}
	else if (parm[0] == "1402")	{quesCnt =  38;  appHt = 390;}
	else if (parm[0] == "1403")	{quesCnt =  26;  appHt = 195;}

	else if (parm[0] == "1501")	{quesCnt =  81;  appHt = 222;}
	else if (parm[0] == "1502")	{quesCnt =  26;  appHt = 322;}
	else if (parm[0] == "1503")	{quesCnt =   6;  appHt = 204;}

	else if (parm[0] == "1601")	{quesCnt =  38;  appHt = 237;}
	else if (parm[0] == "1602")	{quesCnt =  13;  appHt = 240;}
	else if (parm[0] == "1603")	{quesCnt =  17;  appHt = 390;}
	else if (parm[0] == "1604")	{quesCnt =  61;  appHt = 331;}
	else if (parm[0] == "1605")	{quesCnt =   3;  appHt = 210;}
	else if (parm[0] == "1606")	{quesCnt =   4;  appHt = 330;}
	else if (parm[0] == "1607")	{quesCnt =   8;  appHt = 225;}
	else if (parm[0] == "1608")	{quesCnt =   3;  appHt = 225;}
	else if (parm[0] == "1609")	{quesCnt =   8;  appHt = 180;}
	else if (parm[0] == "1610")	{quesCnt =   5;  appHt = 180;}
	else if (parm[0] == "1611")	{quesCnt =  13;  appHt = 255;}

	else if (parm[0] == "1701")	{quesCnt =  35;  appHt = 249;}
	else if (parm[0] == "1702")	{quesCnt =  11;  appHt = 225;}
	else if (parm[0] == "1703")	{quesCnt =   8;  appHt = 355;}
	else if (parm[0] == "1704")	{quesCnt =   1;  appHt = 204;}
	else if (parm[0] == "1705")	{quesCnt =  62;  appHt = 386;}
	else if (parm[0] == "1706")	{quesCnt =  10;  appHt = 180;}
	else if (parm[0] == "1707")	{quesCnt =  12;  appHt = 180;}
	else if (parm[0] == "1708")	{quesCnt =   7;  appHt = 192;}
	else if (parm[0] == "1709")	{quesCnt =   6;  appHt = 196;}

	else if (parm[0] == "1801")	{quesCnt =  28;  appHt = 212;}
	else if (parm[0] == "1802")	{quesCnt =  18;  appHt = 390;}
	else if (parm[0] == "1803")	{quesCnt =  43;  appHt = 234;}

	else if (parm[0] == "1901")	{quesCnt =  63;  appHt = 222;}
	else if (parm[0] == "1902")	{quesCnt =  78;  appHt = 252;}
	else if (parm[0] == "1903")	{quesCnt =  10;  appHt = 223;}
	else if (parm[0] == "1904")	{quesCnt =  60;  appHt = 252;}
	else if (parm[0] == "1905")	{quesCnt =  12;  appHt = 240;}
	else if (parm[0] == "1906")	{quesCnt =  66;  appHt = 340;}
	else if (parm[0] == "1907")	{quesCnt =   9;  appHt = 195;}
	else if (parm[0] == "1908")	{quesCnt =   9;  appHt = 192;}
	else if (parm[0] == "1909")	{quesCnt =   4;  appHt = 192;}
	else if (parm[0] == "1910")	{quesCnt =   4;  appHt = 222;}

	else if (parm[0] == "2001")	{quesCnt =  45;  appHt = 282;}
	else if (parm[0] == "2002")	{quesCnt =   9;  appHt = 286;}
	else if (parm[0] == "2003")	{quesCnt =  13;  appHt = 210;}
	else if (parm[0] == "2004")	{quesCnt =  15;  appHt = 390;}
	else if (parm[0] == "2005")	{quesCnt =  52;  appHt = 244;}
	else if (parm[0] == "2006")	{quesCnt =  12;  appHt = 257;}
	else if (parm[0] == "2007")	{quesCnt =   3;  appHt = 192;}
	else if (parm[0] == "2008")	{quesCnt =   3;  appHt = 195;}
	else if (parm[0] == "2009")	{quesCnt =   3;  appHt = 195;}
	else if (parm[0] == "2010")	{quesCnt =   3;  appHt = 180;}
	else if (parm[0] == "2011")	{quesCnt =  20;  appHt = 195;}

	else if (parm[0] == "2101")	{quesCnt =  33;  appHt = 247;}
	else if (parm[0] == "2102")	{quesCnt =  11;  appHt = 207;}
	else if (parm[0] == "2103")	{quesCnt =  30;  appHt = 219;}
	else if (parm[0] == "2104")	{quesCnt =  50;  appHt = 390;}
	else if (parm[0] == "2105")	{quesCnt =  32;  appHt = 210;}
	else if (parm[0] == "2106")	{quesCnt = 123;  appHt = 368;}
	else if (parm[0] == "2107")	{quesCnt =   3;  appHt = 192;}
	else if (parm[0] == "2108")	{quesCnt =   3;  appHt = 189;}
	else if (parm[0] == "2109")	{quesCnt =  10;  appHt = 177;}

	else if (parm[0] == "2201")	{quesCnt =  13;  appHt = 237;}
	else if (parm[0] == "2202")	{quesCnt =  19;  appHt = 234;}
	else if (parm[0] == "2203")	{quesCnt =  37;  appHt = 226;}
	else if (parm[0] == "2204")	{quesCnt =  29;  appHt = 390;}
	else if (parm[0] == "2205")	{quesCnt =  51;  appHt = 364;}
	else if (parm[0] == "2206")	{quesCnt =  32;  appHt = 210;}
	else if (parm[0] == "2207")	{quesCnt =  18;  appHt = 252;}
	else if (parm[0] == "2208")	{quesCnt =  16;  appHt = 204;}

	else if (parm[0] == "2301")	{quesCnt =  65;  appHt = 270;}
	else if (parm[0] == "2302")	{quesCnt = 153;  appHt = 379;}
	else if (parm[0] == "2303")	{quesCnt =  16;  appHt = 195;}
	else if (parm[0] == "2304")	{quesCnt =   7;  appHt = 327;}
	else if (parm[0] == "2305")	{quesCnt =   3;  appHt = 267;}
	else if (parm[0] == "2306")	{quesCnt =   4;  appHt = 192;}

	else if (parm[0] == "2401")	{quesCnt =  82;  appHt = 237;}
	else if (parm[0] == "2402")	{quesCnt =  69;  appHt = 371;}
	else if (parm[0] == "2403")	{quesCnt =   3;  appHt = 207;}

	else if (parm[0] == "2501")	{quesCnt =  62;  appHt = 267;}
	else if (parm[0] == "2502")	{quesCnt =  83;  appHt = 389;}
	else if (parm[0] == "2503")	{quesCnt =  18;  appHt = 192;}
	else if (parm[0] == "2504")	{quesCnt =   3;  appHt = 222;}

	else if (parm[0] == "2601")	{quesCnt =  49;  appHt = 237;}
	else if (parm[0] == "2602")	{quesCnt = 118;  appHt = 382;}
	else if (parm[0] == "2603")	{quesCnt =   3;  appHt = 180;}

	else if (parm[0] == "2701")	{quesCnt =  51;  appHt = 246;}
	else if (parm[0] == "2702")	{quesCnt =  88;  appHt = 390;}
	else if (parm[0] == "2703")	{quesCnt =   5;  appHt = 192;}
	else if (parm[0] == "2704")	{quesCnt =   9;  appHt = 189;}
	else if (parm[0] == "2705")	{quesCnt =   5;  appHt = 207;}

	else if (parm[0] == "2801")	{quesCnt =  71;  appHt = 252;}
	else if (parm[0] == "2802")	{quesCnt = 100;  appHt = 390;}
	else if (parm[0] == "2803")	{quesCnt =   4;  appHt = 175;}
	else if (parm[0] == "2804")	{quesCnt =   9;  appHt = 204;}
	else if (parm[0] == "2805")	{quesCnt =  10;  appHt = 192;}

	// load the main frame
	self.applet.document.open();
	self.applet.document.writeln('<html>');
	self.applet.document.writeln('  <body bgcolor="FFFFFF" marginheight=0 marginwidth=0 topmargin=0 leftmargin=0>');
	self.applet.document.writeln('    <applet archive="quiz_eng.jar, quiz_res.jar, quiz' + parm[0] + '.jar"');
	self.applet.document.writeln('            code="QuizEngine.class" codebase="../quiz_eng"');
	self.applet.document.writeln('            width=' + appWd + ' height=' + appHt + '>');
	self.applet.document.writeln('      <param name=background value=16777215>');
	self.applet.document.writeln('      <param name=quesCnt value=' + quesCnt + '>');
	self.applet.document.writeln('      <param name=jarNum value=' + parm[0] + '>');
	self.applet.document.writeln('      <param name=quesType value=' + parm[1] + '>');
	if (parm.length > 1)
	{
		self.applet.document.writeln('      <param name=quesBeg value=' + parm[2] + '>');
	}
	if (parm.length > 2)
	{
		self.applet.document.writeln('      <param name=quesEnd value=' + parm[3] + '>');
	}
	self.applet.document.writeln('    </applet>');
	self.applet.document.writeln('  </body>');
	self.applet.document.writeln('</html>');
	self.applet.document.close();

	return false;
}
